<style>
    .dhh-channel-manage-tab {
        height: 789px;
        margin-top: 10px;
        float: left;
        width: 100%;
    }
    
    .click-opraty {
        font-size: 20px;
        cursor: pointer;
        margin: 5px;
    }
</style>
<div id="dhh-channel-manage" class="show_page_content">
    <!-- 顶部按钮 -->
    <div class="dhh-channel-manage-tab">
        <table id="dhh-channel-manage-table"></table>
    </div>
</div>
<script>
    layui.use(["table"], function() {
        var laytab = layui.table;
        //laydate 时间控件
        var heigth = $("#page-container").height() - 30;
        $(".dhh-channel-manage-tab").height(heigth);
        //搜索
        $("#hometotal-search").on("click", function() {
            laytab.reload('usertable');
        });

        renderTable();
        delRow("#dhh-channel-manage .del", "/admin/adm_del", function() {
            laytab.reload('usertable');
        });

        function renderTable() {
            laytab.render({
                elem: '#dhh-channel-manage-table',
                height: heigth,
                url: "/admin/adm_list",
                method: "get",
                id: "usertable",
                response: {
                    statusName: "result",
                    msgName: 'tips' //规定状态信息的字段名称，默认：msg
                        ,
                    countName: 'total' //规定数据总数的字段名称，默认：count
                        ,
                    dataName: 'rows',
                    statusCode: 1 //规定成功的状态码，默认：0
                },
                request: {
                    pageName: 'page' //页码的参数名称，默认：page
                        ,
                    limitName: 'lines' //每页数据量的参数名，默认：limit
                },
                done: function(d) {
                    $(".layui-none").text(d.tips);
                },
                parseData: function(res) { //res 即为原始返回的数据
                    return {
                        "result": res.result, //解析接口状态
                        "tips": res.tips, //解析提示文本
                        "total": res.total, //解析数据长度
                        "rows": res.rows //解析数据列表
                    }
                },
                cols: [
                    [{
                        title: "序号",
                        field: "uid"
                    }, {
                        title: "用户名",
                        field: "username"
                    }, {
                        title: "所属角色",
                        field: "mid",
                        unresize: true,
                        templet: function(d) {
                            if (d.mid == 0 && d.uid == 1) {
                                return "超级管理员";
                            } else if (d.mid == 0 && d.uid != 1) {
                                return "管理员";
                            }
                        }
                    }, {
                        title: "注册时间",
                        field: "addtime"
                    }, {
                        title: "最后登陆时间",
                        field: "logintime"
                    }, {
                        title: "最后登陆IP",
                        field: "loginip",
                    }, {
                        title: "操作管理",
                        unresize: true,
                        width: "10%",
                        templet: function(d) {
                            if (d.uid == 1 && d.mid == 0) {
                                return "";
                            } else {
                                return "<a class='click-opraty' title='点击删除'><i class='layui-icon layui-icon-delete del' uid='" + d.uid + "' style='color:#393D49;'></i></a>";

                            }

                        }
                    }]
                ],
                page: true,
                limits: [20, 50, 100],
                limit: 20,
                loading: true,
                skin: {
                    even: true
                },
            });
        }
    });
</script>